import uvicorn
from project_utils.a_utils import greet_with_style

from fastapi import FastAPI

from src.inner_util.inner_tool import print_hello

app = FastAPI()

@app.get("/")
def read_root():
    print_hello()
    return {"message": greet_with_style('hello')}

# 带参数的路由
@app.get("/greet/{name}")
def greet_name(name: str):
    return {"message": greet_with_style(name)}

# CMD启动：poetry run python -m src.sub_project_one.module_one
#     or: python -m src.sub_project_one.module_one(这个需要先启动项目虚拟环境)
#     or: uvicorn src.sub_project_one.module_one:app --reload
#     or: PYTHONPATH="${PYTHONPATH}:/your-path-to/sub_project_one/src" /your-path-to/sub_project_one/.venv/bin/python /your-path-to/sub_project_one/src/sub_project_one/module_one.py
# 在 main 中运行应用
if __name__ == "__main__":
    # FastAPI 自动生成交互式 API 文档：
    # Swagger UI： http://127.0.0.1:8000/docs
    # ReDoc ：http://127.0.0.1:8000/redoc
    uvicorn.run(app,  host="0.0.0.0", port=8000)